
package library.holdings;


public class HoldingBase implements Holding, Comparable {

	protected String id;
	protected String title;

	protected HoldingBase(String id, String title) {
		this.id = id;
		this.title = title;
	}

	public void setID(String value) {
		if (value == null || value.length() == 0) {
			throw new IllegalArgumentException();
		}
		id = value;
	}

	public String getID() {
		return id;
	}

	public void setTitle(String value) {
		if (value == null || value.length() == 0) {
			throw new IllegalArgumentException();
		}
		title = value;
	}

	public String getTitle() {
		return title;
	}

	public boolean equals(Object o) {
		if (o != null && o instanceof HoldingBase) {
			HoldingBase other = (HoldingBase)o;
			return (id.equals(other.id) &&
					title.equals(other.title));
		}
		else {
			return false;
		}
	}

	public int compareTo(Object o) {
		Holding h = (Holding)o;
		return title.compareTo(h.getTitle());
	}

}

